package com.example.moviegroup.app;

import java.util.ArrayList;
import android.app.Activity;
import android.content.res.Resources.NotFoundException;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;

import android.widget.Toast;

import com.example.moviegroup.activity.MainActivity;


public abstract class BaseActivity extends Activity {

	protected static final int REQUEST_CODE_ALERT_ACTIVITY = 101;

	//protected BOCNetLib netLib;
	//1m
	protected Activity mActivity;
	protected String selectDate;
	public int width;
	public int height;
	private String currentClass;
	private static String lastClass;

	// private static HashMap<String, Activity> activitys = new HashMap<String,
	// Activity>();
	
	//2,
	public static ArrayList<String> activitys = new ArrayList<String>();

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		//netLib = BOCNetLib.getInstance(this);
		// app = (IApplication) getApplication();
		
		mActivity = this;
		loadXml();
		getIntentData(savedInstanceState);
		init();
		setListener();
		setData();
	}




	/**
	 * 设置xml文件
	 */
	public abstract void loadXml();

	/**
	 * 获取intent数据
	 * 
	 * @param savedInstanceState
	 */
	public abstract void getIntentData(Bundle savedInstanceState);

	/**
	 * view 初始化
	 */
	public abstract void init();

	/**
	 * 设置view监听器
	 */
	public abstract void setListener();

	/**
	 * 数据设置
	 */
	public abstract void setData();

	/**
	 * 长文本提示
	 */
	public void showLongText(String text) {
		Toast.makeText(this, text, Toast.LENGTH_LONG).show();
	}

	/**
	 * 短文本提示
	 */
	public void showShortText(String text) {
		Toast.makeText(this, text, Toast.LENGTH_SHORT).show();
	}

	/**
	 * 短文本提示
	 */
	public void showShortText(int resId) {
		try {
			Toast.makeText(this, mActivity.getResources().getString(resId),
					Toast.LENGTH_SHORT).show();
		} catch (NotFoundException e) {
			e.printStackTrace();
		}
	}

	/**
	 * 长文本提示
	 */
	public void showLongText(int resId) {
		try {
			Toast.makeText(this, mActivity.getResources().getString(resId),
					Toast.LENGTH_LONG).show();
		} catch (NotFoundException e) {
			e.printStackTrace();
		}
	}

	public void showNoAnimation() throws Exception {
		overridePendingTransition(0, 0);
	}

	/**
	 * 增加用户点击home键后，处理逻辑，
	 */
	@Override
	protected void onResume() {
		super.onResume();

	}

	@Override
	protected void onPause() {
		super.onPause();
	}

	@Override
	protected void onStop() {
		super.onStop();
	}

	@Override
	protected void onDestroy() {
		super.onDestroy();
		if (activitys.size() > 0)
			activitys.remove(activitys.size() - 1);
	}

}
